#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string.h>
#pragma comment (linker, "/STACK:64000000")
const int Nmax = 100001;
//int b[Nmax];
struct FenwickTree
{
	int a[Nmax];
	int b[Nmax];
	int n;
};
void Update ( FenwickTree *FTree, int k, int d )
{
	//FTree->a[k] += d;
	while ( k < FTree->n)
	{
		FTree->b[k] += d;
		k = k|(k+1);
	}
}
void Init ( FenwickTree *FTree, int n )
{
	FTree->n = n;
	for ( int i = 0; i < n; i++ )
		FTree->a[i] = 0;
	for ( int i = 0; i < n; i++ )
		FTree->b[i] = 0;
	for ( int i = 0; i < n; i++ )
		Update ( FTree, i, FTree->a[i] );				
}
int rsq( FenwickTree *FTree, int k)
{
	int sum = 0;
	while ( k >=0 )
	{
		sum += FTree->b[k];
		k = (k&(k+1))-1;
		
	}
	return sum;
}
int binpoisk ( FenwickTree *FTree )
{
	int left = -1;
	int right = Nmax;
	int mid;
	int key = rsq ( FTree, 100000);
	key = (key + 1) / 2;
	while ( left + 1 < right )
	{
		mid = ( left + right ) / 2;
		int sum = rsq (FTree, mid);
		if (key >  sum)
			left = mid;
		else right = mid;
	}
	//if ( FTree->b[left] == key )
		return right;
}
int main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	int n, nom;
	int x;
	FenwickTree FTree;
	Init ( &FTree, Nmax );
	scanf ( "%d", &n );
	char s[7];
	for ( int i = 0; i < n; i++ )
	{
		scanf ( "%s%d", s, &x );
		if ( strcmp ( "Insert", s ) == 0 )
			{
				if (FTree.a[x] == 0)
				{
						FTree.a[x] = 1;
						Update ( &FTree, x, 1 );
				}
				nom = binpoisk ( &FTree );
			    printf ( "%d\n", nom );
				
		}
		else
		{
			if (FTree.a[x] == 1) {
				FTree.a[x] = 0;
				Update ( &FTree, x, -1 );
			}
			nom = binpoisk ( &FTree );
			printf ( "%d\n", nom );
		}
	}
}

